/* Test data processing backend */

#include <iomanip>
#include <iostream>
#include <map>
#include <utility>

#include <memchart/class_info.hpp>
#include <memchart/types.hpp>

#include "test_data_sink.hpp"

namespace memchart
{
	using std::clog;
	using std::setw;

	void test_data_sink::update (const string & s)
	{
		clog << "Object listing (message = '" << s << "'):\n";

		/* Iterate over all objects and print their members */
		for (object_map::const_iterator it = objects.begin();
			it != objects.end(); ++it)
		{
			uintptr_t addr = it->first;
			const class_info & info = *it->second;

			clog << "\t" << to_string(addr) << " " << info.name;
			for (size_t i = 0; i < info.count(); ++i)
			{
				clog << "\n\t\t";
				clog << setw(16) << info[i].type << " "
					<< setw(16) << info[i].name << " = "
					<< info[i].read(addr);
			}
			clog << "\n";
		}
	}
}
